package com.um.pasantiaum.empresa;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.parse.ParseUser;
import com.um.pasantiaum.DispatchActivity;
import com.um.pasantiaum.R;
import com.um.pasantiaum.camiones.AdminCamionesActivity;
import com.um.pasantiaum.empresa.pedidos.PedidosButtons;
import com.um.pasantiaum.empresa.productos.AdminProductosActivity;
import com.um.pasantiaum.empresa.usuarios.AdminUserActivity;

public class MainActivityEmpresa extends ActionBarActivity {

	private Button mAdminProd, mAdminUser, mAdminCamiones, mAdminPedidos;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_empresa);

		mAdminProd = (Button) findViewById(R.id.administrar_prod);
		mAdminProd.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(MainActivityEmpresa.this,
						AdminProductosActivity.class);
				startActivity(i);

			}
		});

		mAdminUser = (Button) findViewById(R.id.administrar_user);
		mAdminUser.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(MainActivityEmpresa.this,
						AdminUserActivity.class);
				startActivity(i);
			}
		});

		mAdminCamiones = (Button) findViewById(R.id.administrar_camiones);
		mAdminCamiones.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(MainActivityEmpresa.this,
						AdminCamionesActivity.class);
				startActivity(i);
			}
		});

		mAdminPedidos = (Button) findViewById(R.id.administrar_pedidos);
		mAdminPedidos.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent i = new Intent(MainActivityEmpresa.this,
						PedidosButtons.class);
				startActivity(i);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.log_out_menu, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		switch (item.getItemId()) {
		case R.id.log_out:
			ParseUser.logOut();
			// Start and intent for the dispatch activity
			Intent intent = new Intent(MainActivityEmpresa.this,
					DispatchActivity.class);
			startActivity(intent);
			finish();
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
	}
}
